package com.example.home.findWork.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.home.R;
import com.example.home.findWork.bean.HistoryBean;

import java.util.List;

public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.MyHoldy> {
    private Context context;
    private List<HistoryBean.RowsBean> list;

    public HistoryAdapter(Context context, List<HistoryBean.RowsBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public MyHoldy onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_hist, null);
        return new HistoryAdapter.MyHoldy(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyHoldy holder, int position) {
        HistoryBean.RowsBean rowsBean = list.get(position);
        holder.companyName.setText(rowsBean.getCompanyName());
        holder.postName.setText(rowsBean.getPostName());
        holder.money.setText("薪资："+rowsBean.getMoney());
        holder.satrTime.setText(rowsBean.getSatrTime());
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : list.size();
    }

    public class MyHoldy extends RecyclerView.ViewHolder {
        private TextView postName;
        private TextView companyName;
        private TextView money;
        private TextView satrTime;

        public MyHoldy(@NonNull View itemView) {
            super(itemView);
            postName = itemView.findViewById(R.id.postName);
            companyName = itemView.findViewById(R.id.companyName);
            money = itemView.findViewById(R.id.money);
            satrTime = itemView.findViewById(R.id.satrTime);
        }
    }
}
